package com.oa.entities;

import com.oa.domain.UndeleteEntity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "oa_user_info")
public class UserInfo extends UndeleteEntity<Long> {
    /**
     *
     */
    private static final long serialVersionUID = 3230926699971920018L;

    /** 姓名 **/
    private String realName;

    /** 性别 **/
    private int gender;

    /** 部门 **/
    private Department department;

    /** 部门的id **/
    private Long departmentId;

    /** 电话 **/
    private String telphone;

    /** 地址 **/
    private String address;

    /** 邮编 **/
    private String postcode;

    /** 学历 **/
    private String education;

    /** 入职时间 **/
    private Long jobTime;

    private User user;

    /** 头像 **/
    private String portrait;

    /** 用户的状态 **/
    private int userStatus;

    /** 照片 **/
    private String picture;

    private Position position;

    @Override
    @Id
    @Column(nullable = false,unique = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return super.getId();
    }

    @Override
    public void setId(Long id) {
        super.setId(id);
    }

    @NotNull
    @Column(name = "user_real_name",nullable = false)
    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    @Column(name = "user_info_gender",nullable = false,columnDefinition = "int default 0")
    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "department_id",nullable = false,insertable = false,updatable = false)
    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    @Column(name = "department_id")
    public Long getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }

    @Column(name = "user_info_tel_phone")
    public String getTelphone() {
        return telphone;
    }

    public void setTelphone(String telphone) {
        this.telphone = telphone;
    }

    @Column(name = "user_address")
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        this.education = education;
    }

    @Column(name = "user_info_job_time",nullable = false)
    public Long getJobTime() {
        return jobTime;
    }

    public void setJobTime(Long jobTime) {
        this.jobTime = jobTime;
    }

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(name = "user_portrait")
    public String getPortrait() {
        return portrait;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }

    @Column(name = "user_status",nullable = false,columnDefinition = "int default 0")
    public int getUserStatus() {
        return userStatus;
    }

    public void setUserStatus(int userStatus) {
        this.userStatus = userStatus;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "realName='" + realName + '\'' +
                ", gender=" + gender +
                ", departmentId=" + departmentId +
                ", telphone='" + telphone + '\'' +
                ", address='" + address + '\'' +
                ", postcode='" + postcode + '\'' +
                ", education='" + education + '\'' +
                ", jobTime=" + jobTime +
                ", portrait='" + portrait + '\'' +
                ", userStatus=" + userStatus +
                '}';
    }

    @Column(name = "user_info_picture")
    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "position_id")
    public Position getPosition() {
        return position;
    }

    public void setPosition(Position position) {
        this.position = position;
    }
}
